﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.DirectX;

namespace SimulationPresenter.Simulation.Primitive
{
    internal class RidigBox : IRidig
    {
        public Matrix Transformation
        {
            get ; set;
        }

        #region Updateable

        private float density;
        /// <summary>
        /// Desired density of an element
        /// </summary>
        public float Density
        {
            get
            {
                return density;
            }
            set
            {
                density = value;
                NeedsUpdate = true;
            }
        }

        private Vector3 size;
        /// <summary>
        /// Desired size of an element. Defined as 3 dimensions.
        /// </summary>
        public Vector3 SizeVector
        {
            get
            {
                return size;
            }
            set
            {
                NeedsUpdate = true;
                size = value;
            }
        }
        /// <summary>
        /// Desired size of an element. Defined as scalar (same size will be used for X, Y, Z)
        /// </summary>
        public float SizeScalar
        {
            set
            {
                SizeVector = new Vector3(value, value, value);
            }
        }
        #endregion

        /// <summary>
        /// Indicates if Core representation should be updated with new values.
        /// </summary>
        public bool NeedsUpdate
        {
            get; set;
        }

        /// <summary>
        /// Gets or Sets Core Actor Name
        /// </summary>
        public string Name
        {
            get; set;
        }

        /// <summary>
        /// Adds element to simulation enviroment
        /// </summary>
        /// <param name="initialPosition"></param>
        /// <param name="enviroment"></param>
        /// <returns></returns>
        public ISimulationPrimitive PutOrUpdate(SimulationEnvironment enviroment)
        {
            Transformation = enviroment.Core.AddBox(SizeVector, Transformation, Name);
            return this;
        }
        
    }
}
